import App from './App'

// #ifndef VUE3
import Vue from 'vue'
Vue.config.productionTip = false
App.mpType = 'app'
const app = new Vue({
	...App
})
app.$mount()
// #endif


import configs from './config/wap.js'
Vue.prototype.$config = configs;


//时间格式
Vue.filter('ysTime', (value) => {
	if (value == '' || value == undefined) return;
	var date = new Date(value * 1000); //时间戳为10位需*1000，时间戳为13位的话不需乘1000
	var year = date.getFullYear();
	var month = ("0" + (date.getMonth() + 1)).slice(-2);
	var sdate = ("0" + date.getDate()).slice(-2);
	var hour = ("0" + date.getHours()).slice(-2);
	var minute = ("0" + date.getMinutes()).slice(-2);
	var second = ("0" + date.getSeconds()).slice(-2);
	// 拼接
	var result = year + "-" + month + "-" + sdate;
	// 返回
	return result;
})

//图片路径拼接
Vue.filter("getImg", (url) => {
	return configs.websiteUrl + url
})


uni.$showMsg = function(title = "数据加载失败！", callback = null, duration = 1500) {
	uni.showToast({
		title: title.toString(),
		duration,
		icon: 'none'
	})
	if (callback) {
		setTimeout(() => {
			callback()
		}, duration)
	}
}

Vue.mixin({
	data() {
		return {

		}
	},
	onShareAppMessage() {

	},
	onShareTimeline() {

	},
	methods: {
		toPage(url) {
			uni.navigateTo({
				url
			})
		},
		checkEnvironment() {
			// #ifndef MP-WEIXIN
			let userAgent = navigator.userAgent.toLowerCase();
			let isWeChat = userAgent.indexOf('micromessenger') !== -1;
			let isRegularBrowser = !isWeChat;

			return {
				isWeChat: isWeChat,
				isRegularBrowser: isRegularBrowser
			};
			// #endif
			// #ifdef MP-WEIXIN
			return {
				isWeChat: true,
				isRegularBrowser: false
			};
			// #endif

		}
	}
})



// #ifdef VUE3
import {
	createSSRApp
} from 'vue'
export function createApp() {
	const app = createSSRApp(App)
	return {
		app
	}
}
// #endif